package cn.autowired.exam.base;

import java.util.HashMap;

/**
 * @Description:  通用的返回类型

 * @version:
 */
public class CommonResponse extends HashMap<String,Object> {


    public static CommonResponse build(){
        return new CommonResponse();
    }

    public static CommonResponse ok(Object data){
        CommonResponse hashMap = CommonResponse.build();
        hashMap.put("code",0);
        hashMap.put("msg","success");
        hashMap.put("data",data);
        return hashMap;
    }

    public static CommonResponse ok(){
        CommonResponse hashMap = CommonResponse.build();
        hashMap.put("code",0);
        hashMap.put("msg","success");
        return hashMap;
    }

    public static CommonResponse error(){
        CommonResponse hashMap = CommonResponse.build();
        hashMap.put("code",-1);
        hashMap.put("msg","error");
        return hashMap;
    }
}
